<template>
    <h3>登入</h3>
    <table border="1">
        <tbody>
            <tr>
                <th>账号</th>
                <th>
                    <input type="text"  v-model="data.Name">
                </th>
            </tr>
            <tr>
                <th>密码</th>
                <th>
                    <input type="text"  v-model="data.Pwd">
                </th>
            </tr>
            <tr>
                <th colspan="2">
                    <input type="button" value="登入" @click="Deng">
                </th>
               
            </tr>
        </tbody>

    </table>
</template>

<script setup lang="ts">


    import axios from 'axios';
    import { ref } from 'vue';


    const data= ref({
        "Id": 0,
        "Name": "",
        "Pwd": "",
        "Phone": "",
        "Addr": ""
    })
    const Deng=()=>{
        if(data.value.Name==""){
            alert('账号不能为空')
            return;
        }
        if(data.value.Pwd==""){
            alert('密码不能为空')
            return;
        }
        axios.get("https://localhost:7011/api/Member/Login",{params:data.value}).then(res=>{
            if(res.data.Id>0){
                alert('登入成功')
                return;
            }
            if(res.data.Id==-1){
                alert('帐号不存在')
                return;
            }
            if(res.data.Id==-2){
                alert('密码不正确')
                return;
            }



        })
    }

</script>

